<?php
/**
 * Created by PhpStorm.
 * User: gr
 * Date: 2017/3/3
 * Time: 10:27
 */

namespace Common\Model;


class HospitalTreatModel extends AiModel
{

    private function _getData()
    {
        $result = $this->select();
        return $result;
    }

    /**
     * 住址特色列表
     * @return array
     */
    public function getList()
    {
        $list = $this->_getData();
        if (is_null($list)) {
            return array();
        } else {
            $new_list = array();
            foreach ($list as $treat) {
                $new_list[$treat['id']] = $treat['name'];
            }
            return $new_list;
        }
    }

    /**
     * @param $treat_id
     * @return array|null
     */
    public function getTreatById($treat_id)
    {
        $where = array('id' => $treat_id);
        $treat = $this->where($where)->find();
        return $treat;
    }

    /**
     * @param $treat_id
     * @return string
     */
    public function getTreatNameById($treat_id)
    {
        $where = array('id' => $treat_id);
        $name = $this->where($where)->getField('name');
        return is_null($name) ? '' : $name;
    }

}